//package wmmd.disc.webmaster;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class PostNewTopic extends HttpServlet {
    
    //----------------------------------------------------------------------------------------
    /**
     * Called by displaymessage.jsp; writes out the HTML form for posting a new topic
     */
    
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        
        //Get the person's username from the REMOTE_USER environment variable to set as the name.
        String UName = request.getRemoteUser();
        if(UName==null) {
            //Assign the name "Guest" (for now)
            UName = "Guest  ";
        }
        UName = UName.substring(0, (UName.length() - 2));
        
        out.println("<H2>New Topic</H2>");
        out.print("<P>To submit a new topic, fill out the form below.");
        out.print("When you are satisfied, Click on the button that");
        out.println(" says 'Post New Topic' </P><HR>");
        out.println("<form method=\"POST\" action=\"postform.jsp\">");
        out.println("<input type=\"HIDDEN\" name=\"RTID\" value=\"1\">");
        out.println("<table width=\"100%\" border=\"3\">");
        out.println("<tr><td align=\"right\">Name:</td>");
        out.println("<td align = left>");
        out.println("<input type=\"text\" readonly=\"readonly\" name=\"NAME\" value=\"" + UName + "\"></td>");
        out.println("<td align=\"right\">Topic:</td><td align=\"left\">");
        out.println("<input type=\"text\"  name=\"SUBJECT\" value=\"Type Topic Here\" onFocus=\"if(!this.initialyCleared){this.value='';this.initialyCleared = true;}\">");
        out.println("</td></tr>");
        out.println("<tr><td align=\"right\">Starting Message</td>");
        out.println("<td colspan=\"3\" align=\"left\">");
        out.println("<textarea name=\"MESSAGE\" COLS=\"60\" rows=\"10\" WRAP onFocus=\"if(!this.initialyCleared){this.value='';this.initialyCleared = true;}\">");
        out.println("Type the message to start the topic here</textarea></td></tr>");
        out.println("</table>");
        out.println("<input type=\"SUBMIT\" name=\"SSC\" value=\"Post New Topic\">");
        out.print("<input type=\"RESET\" value=\"Clear Fields\">");
        out.print("</FORM>");
    }
}
